//
//  YXHomeView.m
//  CreditCard
//
//  Created by 杨旭 on 2017/12/21.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "YXHomeView.h"
#import "YXHomeMenuView.h"
#import "YXHomeCarMenuView.h"
@interface YXHomeView ()
@property (nonatomic ,strong) UIScrollView *scrollView;
@end

@implementation YXHomeView

- (UIScrollView *)scrollView {
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc] initWithFrame:self.bounds];
        _scrollView.backgroundColor = color_backColor;
        _scrollView.contentSize = CGSizeMake(kScreenWidth, kScreenHeight * 2);
    }
    return _scrollView;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.scrollView];
        [self createThirdBtnViewUI];
        [self createMenuViewUI];
//        [self createCarMenuViewUI];
    }
    return self;
}

- (void)createThirdBtnViewUI {
    
    UIView *backView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, kScreenWidth, 150))];
    backView.backgroundColor = color_globalColor;
    [self.scrollView addSubview:backView];
    
    NSArray *imageArr = @[@"014",@"013",@"012"];
    NSArray *titleArr = @[@"二维码",@"添加合伙人",@"钱包"];
    for (int i = 0 ; i < titleArr.count; i ++ ) {
        UIButton *btn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        btn.frame = CGRectMake(self.frame.size.width/3 * i + self.frame.size.width/3/2 -50 , 20, 100, 100);
        [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",imageArr[i]]] forState:(UIControlStateNormal)];
        [btn setTitle:titleArr[i] forState:(UIControlStateNormal)];
        [btn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        [btn setImgViewStyle:(ButtonImgViewStyleTop) imageSize:(CGSizeMake(60, 60)) space:10];
        [backView addSubview:btn];
    }

}

- (void)createMenuViewUI {
    
    YXHomeMenuView *menuView = [[YXHomeMenuView alloc] initWithFrame:(CGRectMake(0, 160, kScreenWidth, 150)) withDataArray:nil];
    [self.scrollView addSubview:menuView];
    
    [menuView setSelectBtnClickBlock:^(NSInteger index) {
        NSLog(@"%ld",index);
    }];
}



- (void)createCarMenuViewUI {
    
    YXHomeCarMenuView *carLifeMenuView = [[YXHomeCarMenuView alloc] initWithFrame:(CGRectMake(0, 160, kScreenWidth, 140)) withTitle:@"卡友好生活" withBtnTitleArr:@[@"卡友论坛",@"机具物料"] withBtnImageArr:@[@"007",@"006"]];
    [self.scrollView addSubview:carLifeMenuView];
    
    YXHomeCarMenuView *carYoungMenuView = [[YXHomeCarMenuView alloc] initWithFrame:(CGRectMake(0, 320, kScreenWidth, 140)) withTitle:@"年轻无极限" withBtnTitleArr:@[@"奖励公告",@"创业扶持",@"助飞梦想"] withBtnImageArr:@[@"005",@"004",@"003"]];
    [self.scrollView addSubview:carYoungMenuView];
    
    YXHomeCarMenuView *carClassMenuView = [[YXHomeCarMenuView alloc] initWithFrame:(CGRectMake(0, 480, kScreenWidth, 140)) withTitle:@"卡友辅助班" withBtnTitleArr:@[@"卡友课堂",@"推荐办卡"] withBtnImageArr:@[@"002",@"001"]];
    [self.scrollView addSubview:carClassMenuView];

}


@end
